package mapkit.layers
{
	import flash.geom.Point;

	import mapkit.carto.Envelope;
	import mapkit.carto.IMap;
	import mapkit.carto.IMapLocator;
	import mapkit.carto.MapLocator;
	import mapkit.carto.Location;

	public class TileDefinition implements IMap
	{
		final public function get width():Number
		{
			return tileWidth * colCount * scale;
		}

		final public function get height():Number
		{
			return tileHeight * rowCount * scale;
		}

		private var _extent:Envelope=new Envelope();

		final public function get extent():Envelope
		{
			return _extent;
		}

		final public function set extent(value:Envelope):void
		{
			_extent=value;
		}

		final public function get center():Location
		{
			return extent.center;
		}

		private var _tilewidth:Number=256;

		final public function get tileWidth():Number
		{
			return _tilewidth;
		}

		final public function set tileWidth(value:Number):void
		{
			_tilewidth=value;
		}

		private var _tileheight:Number=256;

		final public function get tileHeight():Number
		{
			return _tileheight;
		}

		final public function set tileHeight(value:Number):void
		{
			_tileheight=value;
		}

		private var _colcount:int=2;

		final public function get colCount():int
		{
			return _colcount;
		}

		final public function set colCount(value:int):void
		{
			_colcount=value;
		}

		private var _rowcount:int=1;

		final public function get rowCount():int
		{
			return _rowcount;
		}

		final public function set rowCount(value:int):void
		{
			_rowcount=value;
		}

		private var _scale:Number=1;

		final public function get scale():Number
		{
			return _scale;
		}

		final public function set scale(value:Number):void
		{
			_scale=value;
		}

		private var _locator:IMapLocator=new MapLocator();

		final public function get locator():IMapLocator
		{
			return _locator;
		}

		final public function set locator(value:IMapLocator):void
		{
			_locator=value;
		}

		final public function toMapPoint(pt:Point):Location
		{
			return locator.toMapPoint(pt, this);
		}

		final public function fromMapPoint(loc:Location):Point
		{
			return locator.fromMapPoint(loc, this);
		}

		virtual public function getExtent(tile:TileInfo):Envelope
		{
			return null;
		}

		virtual public function getTileExtent(map:IMap):TileGrid
		{
			return null;
		}

	}
}